Skip to content

Conversation

arepala-uml
Copy link
Contributor

  1. Added TransactionMetadatum type to properly encode and decode transaction metadata as defined in the CDDL.
  2. TransactionMetadatum replaces the use of cbor.LazyValue across each era transaction and supports decoding of int, bytes, text, lists, and maps.

Closes #1136

@arepala-uml arepala-uml marked this pull request as ready for review August 25, 2025 18:47
@arepala-uml arepala-uml requested a review from a team as a code owner August 25, 2025 18:47
Copy link
Contributor

@agaffney agaffney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need something like a TransactionMetadatumWrapper type, which can be used in a Transaction type and call the decode functions, similar to what you're doing in TransactionMetadataSet.

)
} else {
t.Logf("Length mismatch: original length = %d, re-encoded length = %d", len(dataBytes), len(encoded))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to keep the check for the re-encoded CBOR being identical to the original decoded CBOR. If that's failing with this new code, then that should be addressed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will revert back the changes here

Type() int
Cbor() []byte
Metadata() *cbor.LazyValue
Metadata() TransactionMetadataSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to use TransactionMetadataSet here, only TransactionMetadatum. The Set is used at the block level to return the metadatum for all TXs included in the block.

type TransactionMetadataSet map[uint64]TransactionMetadatum

type TransactionMetadatum interface {
TypeName() string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a isTransactionMetadatum() function here, so that other types can't accidentally satisfy this interface.

TransactionBodies []ConwayTransactionBody
TransactionWitnessSets []ConwayTransactionWitnessSet
TransactionMetadataSet map[uint]*cbor.LazyValue
TransactionMetadataSet map[uint]common.TransactionMetadataSet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be TransactionMetadataSet TransactionMetadataSet. What you've got here will give you nested maps, which isn't what we want

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean TransactionMetadataSet.TransactionMetadataSet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, I meant TransactionMetadataSet common.TransactionMetadataSet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support proper encoding/decoding of TX metadata
2 participants